package com.sunwayworld.basemodule.rm.environment.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.sunwayworld.framework.at.annotation.AuditTrailType;
import com.sunwayworld.framework.at.annotation.AuditTrailEntry;
import com.sunwayworld.framework.spring.annotation.GikamBean;

import com.sunwayworld.basemodule.rm.environment.dao.LimsEnvironmentRoomDao;
import com.sunwayworld.basemodule.rm.environment.bean.LimsEnvironmentRoomBean;
import com.sunwayworld.basemodule.rm.environment.service.LimsEnvironmentRoomService;
import com.sunwayworld.framework.context.ApplicationContextHelper;
import com.sunwayworld.framework.restful.data.RestJsonWrapperBean;

@Repository
@GikamBean
public class LimsEnvironmentRoomServiceImpl implements LimsEnvironmentRoomService {

    @Autowired
    private LimsEnvironmentRoomDao limsEnvironmentRoomDao;

    @Override
    @SuppressWarnings("unchecked")
    public LimsEnvironmentRoomDao getDao() {
        return limsEnvironmentRoomDao;
    }

    @Override
    @Transactional
    @AuditTrailEntry(AuditTrailType.INSERT)
    public Long insert(RestJsonWrapperBean jsonWrapper) {
        LimsEnvironmentRoomBean limsEnvironmentRoom = jsonWrapper.parseUnique(LimsEnvironmentRoomBean.class);
        limsEnvironmentRoom.setId(ApplicationContextHelper.getNextIdentity());
        getDao().insert(limsEnvironmentRoom);
        return limsEnvironmentRoom.getId();
    }

}
